<?php

use yii\helpers\Html;
use yii\widgets\DetailView;


$this->title = 'Invoice 详情';
$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Invoices'), 'url' => ['index','product_id'=>$model->product_id]];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="invoice-view">

    <div class="box">
        <div class="box-header">
        <?= Html::a(Yii::t('app', 'Update'), ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
        </div>
        <div class="box-body">
            <div class="col-md-6">
            <?= DetailView::widget([
                'model' => $model,
                'attributes' => [
                
                    'product.code',
                    'product.name',
                    'code',
                    'price',
                    'download_time',
                    'payment_date',
                    [
                        'attribute' => 'pay_type',
                        'value' => function ($model) {
                                return isset(Yii::$app->params['invoice_pay_type'][$model->pay_type])?Yii::$app->params['invoice_pay_type'][$model->pay_type]:'';
                            },
                    ],
                    [
                        'attribute' => 'status',
                        'value' => function ($model) {
                                return isset(Yii::$app->params['status'][$model->status])?Yii::$app->params['status'][$model->status]:'';
                            },
                    ],
                    [
                      'attribute' => 'user_id',
                      'value' => function($model){

                            return $model->userName;
                      }
                    ],
                    'created_at',
                    'updated_at',
                ],
            ]) ?>
            </div>
            <div class="col-md-6">
                <h4>Invoice详情</h4>
                <table class="table table-striped table-bordered detail-view">
                    <thead>
                        <tr>
                            <td>数量</td>
                            <td>单价</td>
                            <td>备注</td>
                        </tr>
                    </td>
                    </thead>
                    <tbody>
                        <?php if($model->invoiceDetail){ ?>
                            <?php foreach($model->invoiceDetail as $em){ ?>
                                <tr>
                                    <td><?=$em->num?></td>
                                    <td><?=$em->s_price?></td>
                                    <td><?=$em->remark?></td>
                                </tr>
                        <?php } }?>
                    </tbody>
                </table>
            </div>    
        </div>
    </div>
</div>
